let reqPathList = []
function initFn() {
  const requireComponents = require.context('.', true, /\.vue/)
  requireComponents.keys().forEach(fileName => {
    const reqCom = requireComponents(fileName)
    // 截取路径作为组件名
    const reqComName = reqCom.name || fileName.replace(/\.\/(.*)\.vue/, '$1')
    reqPathList.push(reqComName)
  })
}
function getComponent(previewList) {
  initFn()
  let result={}
  for (let i = 0; i < reqPathList.length; i++){
    let path = reqPathList[i]
    previewList.value.forEach(e => {
      if (path.includes(e.type)) {
        result[e.type] = path
      }
    })
  }
  return result
}

export default  getComponent 
